<template>
	<view class="item">
		<view class="bg-white press-down-active" style="padding: 5px 10px; margin-bottom: 10px; border-radius: 4px;">
			<view class="Media">
				<view style="width: 45px; height: 45px; position: relative;">
					<u--image shape="circle" :src="info.headimgurl" width="45px" height="45px" @click="handlePopup" />
					<u--image v-if="info.is_subscribe" shape="circle" :src="wx_png" width="24" height="24" style="position: absolute; bottom: 0; right: 0;" />
				</view>
				<view class="Media-body text-xs" style="padding: 0 10px;">
					<view class="Grid">
						<view style="margin-bottom: 10px;">【{{info.wechat_info.title}}】会员ID:{{info.member_id}}</view>
						<view class="Grid-cell text-right">{{status[info.status]}}</view>
					</view>
					<view class="Grid">
						<view>{{info.nickname}}</view>
						<view class="Grid-cell text-right">{{info.create_time}}</view>
					</view>
				</view>
			</view>
			<view class="Grid Grid--center Grid--justifyFlexEnd">
				<!-- <u-button v-if="info.im_user_id" type="warning" shape="circle" @click="handleIm()" style="width: 80px; font-size: 12px; height: 32px; margin: 5px;">私信</u-button> -->
				<u-button v-if="info.status == 1" type="info" shape="circle" @click="handleSetFans(2)" style="width: 80px; font-size: 12px; height: 32px; margin: 5px;">拉黑</u-button>
				<u-button v-if="info.status == 2" type="info" shape="circle" @click="handleSetFans(1)" style="width: 80px; font-size: 12px; height: 32px; margin: 5px;">取消拉黑</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		parseQuery
	} from '@/utils/index.js'
	import wx_png from '@/static/images/my/wx.png'
	
	const {
		appid
	} = parseQuery()
	
	export default {
		name: 'item',
		props: {
			info: {
				type: Object,
				default: () => ({})
			}
		},
		computed: {

		},
		data() {
			return {
				wx_png,
				status: {
					1: '已关注',
					2: '已拉黑',
					3: '已取关',
					4: '已拉黑并取关'
				},
				statusSetFansMap: {
					1: '取消拉黑',
					2: '拉黑'
				}
			}
		},
		methods: {
			handlePopup() {
				this.$emit('handlePopup', this.info)
			},
			handleIm() {
				const conversationID = `C2C${this.info.im_user_id}`;
				uni.navigateTo({ url: `/TUIKit/components/TUIChat/index?appid=${appid}&key=pc&conversationID=${conversationID}&nickname=${this.info.nickname}`});
			},
			handleSetFans(status) {
				uni.showModal({
					content: `确认将该用户${this.statusSetFansMap[status]}?`,
					success: (res) => {
						if (res.confirm) {
							this.$emit('handleSetFans', {
								member_id: this.info.member_id,
								status
							})
						} else if (res.cancel) {}
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		padding: 0 10px;
	}
</style>